<template>
  <div class="bg-light">
    <div class="container-title">签约信息</div>
    <Form ref="form" :rules="rule" :model="form" style="display:flex;flex-wrap:wrap">
      <div style="flex:1;padding-left:30px;margin-right:10px">
        <FormItem label="门店名称: " prop="name">
          <p :class="sc.storeNameOrg?'font-pink':''">
            <span v-if="sc.storeNameOrg">{{ sc.storeNameOrg }} 更改为 </span> {{ sc.storeName }}</p>
        </FormItem>
        <FormItem label="营业执照编号: " prop="name">
          <p :class="sc.businessLicenseNoOrg?'font-pink':''">
            <span v-if="sc.businessLicenseNoOrg">{{ sc.businessLicenseNoOrg }} 更改为 </span> {{ sc.businessLicenseNo }}
            <Button v-if="showJudge" type="primary" class="ml" size="small" @click="onConfirmNo">验证编号</Button>
            <Tag v-show="isValideNo == 'success'" color="warning">存在</Tag>
            <Tag v-show="isValideNo == 'fail'" color="success">不存在</Tag>
          </p>
        </FormItem>
        <FormItem label="经销商: " prop="name">
          <span :class="sc.distributorNameOrg?'font-pink':''"><span v-if="sc.distributorNameOrg">{{ sc.distributorNameOrg }} 更改为 </span>{{ sc.distributorName }}</span>
        </FormItem>
        <FormItem label="签约品牌: " prop="name">
          <p><span v-if="brandMain">
            <span :class="sc.brandNameOrg?'font-pink':''">
              <span v-if="sc.brandNameOrg">{{ sc.brandNameOrg }} 更改为 </span> {{ sc.brandName }}</span>
            <span v-if="brandGuanlian.length">(<span v-for="i in brandGuanlian" :key="i.brandId" class="ml mr font-blue">{{ i.brandName }}</span>)</span>
          </span>
          </p>
        </FormItem>
        <FormItem label="授权品牌绑定: " prop="name">
          <p><span v-for="i in form.empowerBrandDTOList" :key="i.brandId" class="ml font-blue">{{ i.brandName }}</span></p>
        </FormItem>
        <FormItem label="门店类型: " prop="name">
          <p :class="sc.storeTypeNameOrg?'font-pink':''">
            <span v-if="sc.storeTypeNameOrg">{{ sc.storeTypeNameOrg }} 更改为</span>
            {{ sc.storeTypeName }}
            <template v-if="sc.storeTypeEnableNow === true">审核当月生效
              <Tooltip class="custom-tooltip" transfer placement="top">
              <Icon type="ios-help-circle" />
              <div slot="content" style="white-space: normal">
              注意：月度积分返利/季度积分返利/门店基金/门店任务量，当月所有数据按新门店类型来计算，次月审核时以前一个月最后一刻门店类型来执行相关逻辑
              </div>
              </Tooltip>
            </template>
            <template v-if="sc.storeTypeEnableNow === false">审核次月生效<Tooltip class="custom-tooltip" transfer placement="top">
              <Icon type="ios-help-circle" />
              <div slot="content" style="white-space: normal">
                注意：月度积分返利/季度积分返利/门店基金/门店任务量，下个月开始执行新门店类型的相关逻辑
              </div>
              </Tooltip>
            </template>
          </p>
        </FormItem>
        <FormItem label="门店任务量: " prop="name">
          <p :class="sc.storeTaskQuantityOrg?'font-pink':''">
            <span v-if="sc.storeTaskQuantityOrg">{{ sc.storeTaskQuantityOrg }} 更改为</span>
            {{ sc.storeTaskQuantity }}
          </p>
        </FormItem>
        <FormItem label="门头编号: " prop="name">
          <p :class="sc.storeNoOrg?'font-pink':''">
            <span v-if="sc.storeNoOrg">{{ sc.storeNoOrg }} 更改为</span>
            {{ sc.storeNo }}</p>
        </FormItem>
        <FormItem label="备注信息: " prop="name">
          <p>{{ sc.memo }}</p>
        </FormItem>
        <FormItem label="扩展字段1: ">
          <p>{{ findExtendStr('brandId') }}</p>
        </FormItem>
        <FormItem label="扩展字段2: ">
          <p>{{ findExtendStr('storeTypeId') }}</p>
        </FormItem>
      </div>
      <div style="flex:1;margin-right:10px">
        <FormItem label="签约状态: ">
          <p :class="sc.contractStatusStrOrg?'font-pink':''">
            <span v-if="sc.contractStatusStrOrg">{{ sc.contractStatusStrOrg }} 更改为</span>
            {{ sc.contractStatusStr }}</p>
        </FormItem>
        <FormItem label="签约审核通过时间: " prop="name">
          <p>{{ sc.enableDate }}</p>
        </FormItem>
        <FormItem label="门店合同确认时间: " prop="name">
          <p>{{ sc.storeContractAgreementDTO && sc.storeContractAgreementDTO.signConfirmDate }}</p>
        </FormItem>
        <FormItem label="门店维护人: " prop="name">
          <p :class="sc.salesmanNameOrg?'font-pink':''">
            <span v-if="sc.salesmanNameOrg">{{ sc.salesmanNameOrg }} 更改为</span>
            {{ sc.salesmanName }}</p>
        </FormItem>
        <FormItem label="所在区域: " prop="name">
          <p>{{ (sc.provinceName || '')+ (sc.cityName || '') + (sc.areaName || '') }}</p>
        </FormItem>
        <FormItem label="详细地址: " prop="name">
          <p>{{ sc.address }}</p>
        </FormItem>
        <FormItem label="坐标: " prop="name">
          <p>{{ sc.lat }}-{{ sc.lng }}</p>
        </FormItem>
        <FormItem label="店主生日: " prop="name">
          <p> {{ sc.ownerBirthday }}</p>
        </FormItem>
        <FormItem label="签约手机号: " prop="name">
          <p :class="sc.storePhoneOrg?'font-pink':''">
            <span v-if="sc.storePhoneOrg">{{ sc.storePhoneOrg }} 更改为</span>
            {{ sc.storePhone }}</p>
        </FormItem>
        <FormItem label="扩展字段3: ">
          <p>{{ findExtendStr('distributorId') }}</p>
        </FormItem>
        <!-- <FormItem label="门店手机号: " prop="name">
          <p>{{sc.storePhone}}</p>
        </FormItem> -->
      </div>
      <div style="flex:1;padding-right:30px">
        <FormItem label="门店基金开关: ">
          <!-- <span>{{sc.isOpenFund?'开':'关'}}</span> -->
          <p :class="sc.isOpenFundOrg === true || sc.isOpenFundOrg === false?'font-pink':''">
            <span v-if="sc.isOpenFundOrg === true || sc.isOpenFundOrg === false">{{ sc.isOpenFundOrg?'开':'关' }} 更改为</span>
            {{ sc.isOpenFund?'开':'关' }}</p>
        </FormItem>
        <!-- <FormItem label="门店巡店开关: ">
          <p :class="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false?'font-pink':''">
            <span v-if="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false">{{ sc.isOpenInspectionOrg?'开':'关' }} 更改为</span>
            {{ sc.isOpenInspection?'开':'关' }}</p>
        </FormItem> -->
        <FormItem label="工厂业务员巡店开关: ">
          <p :class="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false?'font-pink':''">
            <span v-if="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false">{{ sc.isOpenInspectionOrg?'开':'关' }} 更改为</span>
            {{ sc.isOpenSupplierInspection?'开':'关' }}</p>
        </FormItem>
        <FormItem label="经销商业务员巡店开关: ">
          <p :class="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false?'font-pink':''">
            <span v-if="sc.isOpenInspectionOrg === true || sc.isOpenInspectionOrg === false">{{ sc.isOpenInspectionOrg?'开':'关' }} 更改为</span>
            {{ sc.isOpenDistributorInspection?'开':'关' }}</p>
        </FormItem>
        <FormItem label="轮胎保理赔资格: " prop="name">
          <p :class="sc.isOpenProtectionClaimsOrg === true || sc.isOpenProtectionClaimsOrg === false?'font-pink':''">
            <span v-if="sc.isOpenProtectionClaimsOrg === true || sc.isOpenProtectionClaimsOrg === false">{{ sc.isOpenProtectionClaimsOrg?'是':'否' }} 更改为</span>
            {{ sc.isOpenProtectionClaims?'是':'否' }}</p>
        </FormItem>
        <FormItem label="授信账户: " prop="name">
          <p :class="sc.isOpenCreditAccountOrg === true || sc.isOpenCreditAccountOrg === false?'font-pink':''">
            <span v-if="sc.isOpenCreditAccountOrg === true || sc.isOpenCreditAccountOrg === false">{{ sc.isOpenCreditAccountOrg?'是':'否' }} 更改为</span>
            {{ sc.isOpenCreditAccount?'是':'否' }}</p>
        </FormItem>
        <FormItem label="门店月度进货返利最高条数: " prop="name">
          <p :class="sc.maxRebateQuantityOrg?'font-pink':''">
            <span v-if="sc.maxRebateQuantityOrg">{{ sc.maxRebateQuantityOrg }} 更改为</span>
            {{ sc.maxRebateQuantity }}</p>
        </FormItem>
        <FormItem label="门店进货积分最高条数: " prop="name">
          <p :class="sc.maxPurchaseQuantityIntegralOrg?'font-pink':''">
            <span v-if="sc.maxPurchaseQuantityIntegralOrg">{{ sc.maxPurchaseQuantityIntegralOrg }} 更改为</span>
            {{ sc.maxPurchaseQuantityIntegral }}</p>
        </FormItem>
        <FormItem label="门店基金核算最高条数: " prop="name">
          <p :class="sc.maxFundQuantityOrg?'font-pink':''">
            <span v-if="sc.maxFundQuantityOrg">{{ sc.maxFundQuantityOrg }} 更改为</span>
            {{ sc.maxFundQuantity }}</p>
        </FormItem>
        <FormItem label="门店基金单条轮胎系数: " prop="name">
          <p :class="sc.unitFundOrg?'font-pink':''">
            <span v-if="sc.unitFundOrg">{{ sc.unitFundOrg }} 更改为</span>
            {{ sc.unitFund }}</p>
        </FormItem>
        <FormItem label="入库返利有效天数设置(天): " prop="name">
          <p :class="sc.inRebateExpiredDaysOrg?'font-pink':''">
            <span v-if="sc.inRebateExpiredDaysOrg">{{ sc.inRebateExpiredDaysOrg }} 更改为</span>
            {{ sc.inRebateExpiredDays }}</p>
        </FormItem>
        <FormItem label="扫码定位距离设置（米）: " prop="name">
          <p :class="sc.scanDistanceRangeOrg?'font-pink':''">
            <span v-if="sc.scanDistanceRangeOrg">{{ sc.scanDistanceRangeOrg }} 更改为</span>
            {{ sc.scanDistanceRange }}</p>
        </FormItem>
      </div>
    </Form>
    <FooterBtns />
  </div>
</template>
<script>
import FooterBtns from './FooterBtns'

export default {
  components: {
    FooterBtns
  },
  props: {
    form: {
      type: Object
    },
    isShowSignInfo: {
      type: Boolean,
      default: true
    },
    showJudge: {
      type: Boolean,
      default: false
    }
  },

  data () {
    return {
      isValideNo: ''
    }
  },
  computed: {
    sc () {
      return this.form.storeContractDTO || {}
    },
    brandMain () {
      return this.form.storeContractDTO.storeContractBrandDTOList.find(item => item.brandType == 0) || {}
    },
    brandGuanlian () {
      return this.form.storeContractDTO.storeContractBrandDTOList.filter(item => item.brandType == 1) || {}
    }
  },
  mounted () {
  },
  methods: {
    onConfirmNo () {
      this.$ajaxGet(`/store_contract_audit/audit/${this.sc.storeId}/${this.sc.businessLicenseNo}`).then(res => {
        if (res) {
          this.isValideNo = 'success'
        } else {
          this.isValideNo = 'fail'
        }
      })
    },
    findExtendStr (key) {
      const storeContractSourceDTOList = this.form.storeContractDTO.storeContractSourceDTOList || []
      const result = storeContractSourceDTOList.find(item => item.sourceKey === key)
      return result ? result.sourceStrValue : '-'
    }
  }
}
</script>
